<?php

class In20Years extends CI_Controller{
	public function __construct(){
		parent::__construct();
	}
	
	public function index(){
		$this->load->Model("mimage");
		$userId = $this->session->userdata ( 'userId' );
		$imageName = $this->session->userdata ( 'imageName' );
		if(isset($_POST)){
			$folderName = $this->session->userdata('userId');
			$destination = 'UserUploads/'.$folderName;
			$mode =  0777;
			$mkdirError = !is_dir($destination)?mkdir($destination, $mode):true;
			if(!$mkdirError){
				$this->session->set_flashdata("Error", "There is an error with server");
				redirect(base_url("index.php/FunctionIn20Years/In20Years/index"));
				return;
			}
			$this->mimage->makeIn20Years();
		}
// 		$size = $this->mimage->getSize("./UserUploads/$userId/$imageName");
// 		$data = array('width'=>$size[0], 'height' => $size[1], 'userId'=>$userId, 'imageName'=>$imageName);
// 		$this->load->view("FunctionIn20Years/index", $data);
	}
}